import { h, render } from 'vue'
import messageComponent from './index.vue'

/**
 * @param {String} type 类型
 * @param {String} content 文本
 * @param {Number} duration 时常
 */
export const message = (type = 'success', content, duration = 3000) => {
  const onDestroy = () => {
    render(null, document.body)
  }
  const vnode = h(messageComponent, {
    type,
    content,
    duration,
    destroy: onDestroy
  })
  render(vnode, document.body)
}
